package model

// 设置同步器的unit原数据 {"unit唯一ID": {"lv": 0, "skillList": {}}}
type SyncedUnit struct {
	Lv        int32 `json:"lv" bson:"lv"`
	SkillList map[int32]int32
}

func (this *SyncedUnit) Clone() *SyncedUnit {
	r := *this
	r.SkillList = make(map[int32]int32, len(this.SkillList))
	for k, v := range this.SkillList {
		r.SkillList[k] = v
	}
	return &r
}

type SyncedUnitMgr map[string]*SyncedUnit

func (this SyncedUnitMgr) Get(k string) (v *SyncedUnit) {
	v = this[k]
	if v != nil {
		v = v.Clone()
	}
	return
}

func (this SyncedUnitMgr) Has(k string) bool {
	_, ok := this[k]
	return ok
}
